package com.bank.repository;

import com.bank.entity.CardInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.jpa.repository.Modifying;
import java.util.List;

public interface CardInfoRepository extends JpaRepository<CardInfo, String> {
    List<CardInfo> findByCardIDContaining(String cardID);
    List<CardInfo> findByCustomerID(Long customerID);
    @Query("SELECT c FROM CardInfo c WHERE c.cardID LIKE %:keyword% OR c.customerName LIKE %:keyword%")
    List<CardInfo> findByCardIDOrCustomerName(@Param("keyword") String keyword);
    @Modifying
    @Query("UPDATE CardInfo c SET c.customerName = :customerName WHERE c.customerID = :customerID")
    void updateCustomerNameByCustomerID(@Param("customerID") Long customerID, @Param("customerName") String customerName);
    void deleteByCustomerID(Long customerID);
} 